package com.ymatou.iapi.trading.operate.testcase;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.Order;
import com.ymatou.iapi.trading.operate.parameter.OrderInfoPo;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.req.ApplySalesRefundRequestBean;
import com.ymatou.iapi.trading.operate.parameter.req.ReapplyRefundReq;
import com.ymatou.iapi.trading.operate.parameter.req.SalesRefundInfoBean;
import com.ymatou.iapi.trading.operate.service.ReapplyRefundCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.database.model.YmtRefundBill;
import com.ymttest.database.model.YmtRefundProduct;
import com.ymttest.database.sqlwapper.YmtRefundWapper;
import com.ymttest.utils.DataUtil;

/**
 * 对已关闭退单重新开启接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_ReapplyRefund {
	private static ReapplyRefundReq bean;
	private static ReapplyRefundCall call;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("对已关闭退单重新开启接口");
	}

	@Before
	public void caseUp() {

		bean = new ReapplyRefundReq();
		call = new ReapplyRefundCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReapplyRefund_001() {
		Logger.start(true, "对已关闭退单重新开启成功");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			Order order = placeOrderResp.getOrderList().get(0);

			int sellerId = order.getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			int orderId = order.getOrderId();

			OrderCallService orderCallService = new OrderCallService();

			BigDecimal amount = placeOrderResp.getPayAmount();
			// 付款
			orderCallService.orderPayRequest(userId, amount, tradingId);
			// 卖家接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 发货
			orderCallService.dispatched(orderId, sellerId);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			orderCallService
					.salesrefundfailrequest(applySalesRefundRequestBean);

			bean.setOrderId(orderId);
			bean.setRefundAmount(BigDecimal.TEN);
			bean.setRefundBillNo(applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0).getRefundBillNo());
			bean.setRefundProductNum(1);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("200", call.getString("code"), "验证code");

			// 数据库验证
			YmtRefundWapper ymtRefund = new YmtRefundWapper();
			SalesRefundInfoBean refundInfoBean = applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0);

			String refundBillNo = bean.getRefundBillNo();

			Map m = new HashMap();

			m.put("orderId", orderId);
			m.put("refundBillNo", refundBillNo);

			YmtRefundBill refundBill = ymtRefund.selectRefundBill(m).get(0);

			YmtRefundProduct refundPro = ymtRefund.selectRefundProduct(m)
					.get(0);

			Logger.comment("校验Ymt_RefundBill表");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundBill.getRefundBillNo(),
					"验证RefundBillNo");

			DataUtil.verifyDecimalEquals(bean.getRefundAmount(),
					refundBill.getRefundAmount(), "验证RefundAmount");
			Logger.verifyEquals(0, refundBill.getRefundStatus(),
					"验证RefundStatus");
			DataUtil.verifyDecimalEquals(bean.getRefundAmount(),
					refundBill.getSettlementAmount(), "验证SettlementAmount");
			Logger.verifyEquals(1, refundBill.getSalesRefundStatus(),
					"验证SettlementStatus");
			Logger.verifyEquals(refundInfoBean.getRefundType(),
					refundBill.getRefundType(), "验证RefundType");
			Logger.verifyEquals(refundInfoBean.getReason(),
					refundBill.getReason(), "验证Reason");
			Logger.verifyEquals(sellerId, refundBill.getSellerId(),
					"验证SellerId");
			Logger.verifyEquals(userId, refundBill.getBuyerId(), "验证BuyerId");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");

			DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
					refundBill.getRefundedAmountOfFreight(),
					"验证RefundedAmountOfFreight");

			Logger.comment("校验Ymt_RefundProduct表");
			Logger.verifyEquals(orderId, refundPro.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundPro.getRefundBillNo(),
					"验证RefundBillNo");
			Logger.verifyEquals(refundInfoBean.getCatalogId(),
					refundPro.getCatalogId(), "验证CatalogId");

			Logger.verifyEquals(bean.getRefundProductNum(),
					refundPro.getRefundProductNum(), "验证RefundProductNum");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReapplyRefund_002() {
		Logger.start(true, "退货退款中退单重新开启失败");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			Order order = placeOrderResp.getOrderList().get(0);

			int sellerId = order.getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			int orderId = order.getOrderId();

			OrderCallService orderCallService = new OrderCallService();

			BigDecimal amount = placeOrderResp.getPayAmount();
			// 付款
			orderCallService.orderPayRequest(userId, amount, tradingId);
			// 卖家接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 发货
			orderCallService.dispatched(orderId, sellerId);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			/*			orderCallService
								.salesrefundfailrequest(applySalesRefundRequestBean);*/

			bean.setOrderId(orderId);
			bean.setRefundAmount(BigDecimal.TEN);
			bean.setRefundBillNo(applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0).getRefundBillNo());
			bean.setRefundProductNum(1);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("201", call.getString("code"), "验证code");
			Logger.verifyEquals("102", call.getString("bcode"), "验证bcode");
			Logger.verifyEquals(
					String.format("退款单%s状态不正确", bean.getRefundBillNo()),
					call.getString("msg"), "验证msg");

			Logger.verifyEquals(false, call.getData().getBoolean("success"),
					"验证msg");

			// 数据库验证
			YmtRefundWapper ymtRefund = new YmtRefundWapper();
			SalesRefundInfoBean refundInfoBean = applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0);

			String refundBillNo = bean.getRefundBillNo();

			Map m = new HashMap();

			m.put("orderId", orderId);
			m.put("refundBillNo", refundBillNo);

			YmtRefundBill refundBill = ymtRefund.selectRefundBill(m).get(0);

			YmtRefundProduct refundPro = ymtRefund.selectRefundProduct(m)
					.get(0);

			Logger.comment("校验Ymt_RefundBill表");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundBill.getRefundBillNo(),
					"验证RefundBillNo");

			DataUtil.verifyDecimalEquals(refundInfoBean.getRefundAmount(),
					refundBill.getRefundAmount(), "验证RefundAmount");
			Logger.verifyEquals(0, refundBill.getRefundStatus(),
					"验证RefundStatus");
			DataUtil.verifyDecimalEquals(refundInfoBean.getRefundAmount(),
					refundBill.getSettlementAmount(), "验证SettlementAmount");
			Logger.verifyEquals(1, refundBill.getSalesRefundStatus(),
					"验证SettlementStatus");
			Logger.verifyEquals(refundInfoBean.getRefundType(),
					refundBill.getRefundType(), "验证RefundType");
			Logger.verifyEquals(refundInfoBean.getReason(),
					refundBill.getReason(), "验证Reason");
			Logger.verifyEquals(sellerId, refundBill.getSellerId(),
					"验证SellerId");
			Logger.verifyEquals(userId, refundBill.getBuyerId(), "验证BuyerId");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");

			DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
					refundBill.getRefundedAmountOfFreight(),
					"验证RefundedAmountOfFreight");

			Logger.comment("校验Ymt_RefundProduct表");
			Logger.verifyEquals(orderId, refundPro.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundPro.getRefundBillNo(),
					"验证RefundBillNo");
			Logger.verifyEquals(refundInfoBean.getCatalogId(),
					refundPro.getCatalogId(), "验证CatalogId");

			Logger.verifyEquals(refundInfoBean.getRefundProductNum(),
					refundPro.getRefundProductNum(), "验证RefundProductNum");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReapplyRefund_003() {
		Logger.start(true, "退货退款完成退单重新开启失败");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			Order order = placeOrderResp.getOrderList().get(0);

			int sellerId = order.getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			int orderId = order.getOrderId();

			OrderCallService orderCallService = new OrderCallService();

			BigDecimal amount = placeOrderResp.getPayAmount();
			// 付款
			orderCallService.orderPayRequest(userId, amount, tradingId);
			// 卖家接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 发货
			orderCallService.dispatched(orderId, sellerId);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);

			bean.setOrderId(orderId);
			bean.setRefundAmount(BigDecimal.TEN);
			bean.setRefundBillNo(applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0).getRefundBillNo());
			bean.setRefundProductNum(1);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("201", call.getString("code"), "验证code");
			Logger.verifyEquals("102", call.getString("bcode"), "验证bcode");
			Logger.verifyEquals(
					String.format("退款单%s状态不正确", bean.getRefundBillNo()),
					call.getString("msg"), "验证msg");

			Logger.verifyEquals(false, call.getData().getBoolean("success"),
					"验证msg");

			// 数据库验证
			YmtRefundWapper ymtRefund = new YmtRefundWapper();
			SalesRefundInfoBean refundInfoBean = applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0);

			String refundBillNo = bean.getRefundBillNo();

			Map m = new HashMap();

			m.put("orderId", orderId);
			m.put("refundBillNo", refundBillNo);

			YmtRefundBill refundBill = ymtRefund.selectRefundBill(m).get(0);

			YmtRefundProduct refundPro = ymtRefund.selectRefundProduct(m)
					.get(0);

			Logger.comment("校验Ymt_RefundBill表");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundBill.getRefundBillNo(),
					"验证RefundBillNo");

			DataUtil.verifyDecimalEquals(refundInfoBean.getRefundAmount(),
					refundBill.getRefundAmount(), "验证RefundAmount");
			Logger.verifyEquals(1, refundBill.getRefundStatus(),
					"验证RefundStatus");
			DataUtil.verifyDecimalEquals(refundInfoBean.getRefundAmount(),
					refundBill.getSettlementAmount(), "验证SettlementAmount");
			Logger.verifyEquals(10, refundBill.getSalesRefundStatus(),
					"验证SettlementStatus");
			Logger.verifyEquals(refundInfoBean.getRefundType(),
					refundBill.getRefundType(), "验证RefundType");
			Logger.verifyEquals(refundInfoBean.getReason(),
					refundBill.getReason(), "验证Reason");
			Logger.verifyEquals(sellerId, refundBill.getSellerId(),
					"验证SellerId");
			Logger.verifyEquals(userId, refundBill.getBuyerId(), "验证BuyerId");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");

			DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
					refundBill.getRefundedAmountOfFreight(),
					"验证RefundedAmountOfFreight");

			Logger.comment("校验Ymt_RefundProduct表");
			Logger.verifyEquals(orderId, refundPro.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundPro.getRefundBillNo(),
					"验证RefundBillNo");
			Logger.verifyEquals(refundInfoBean.getCatalogId(),
					refundPro.getCatalogId(), "验证CatalogId");

			Logger.verifyEquals(refundInfoBean.getRefundProductNum(),
					refundPro.getRefundProductNum(), "验证RefundProductNum");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReapplyRefund_004() {
		Logger.start(true, "对已关闭退单重新开启超过最大商品可退金额");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder7();

			Order order = placeOrderResp.getOrderList().get(0);

			int sellerId = order.getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			int orderId = order.getOrderId();

			OrderCallService orderCallService = new OrderCallService();

			BigDecimal amount = placeOrderResp.getPayAmount();
			// 付款
			orderCallService.orderPayRequest(userId, amount, tradingId);
			// 卖家接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 发货
			orderCallService.dispatched(orderId, sellerId);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			orderCallService
					.salesrefundfailrequest(applySalesRefundRequestBean);

			OrderInfoPo po = order.getOrderInfoList().get(0);

			// 计算订单总价格 商品价格 X 数量+运费
			BigDecimal refoundAmout = po.getProductPrice()
					.multiply(new BigDecimal(po.getAmount()))
					.subtract(po.getYmtCouponAmount())
					.subtract(po.getSellerCouponAmount())
					.add(order.getFreight().add(new BigDecimal("0.01")));

			bean.setOrderId(orderId);
			bean.setRefundAmount(refoundAmout);
			bean.setRefundBillNo(applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0).getRefundBillNo());
			bean.setRefundProductNum(1);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("201", call.getString("code"), "验证code");

			Logger.verifyEquals("114", call.getString("bcode"), "验证bcode");
			Logger.verifyEquals(
					String.format("OrderId:%s, 申请退运费金额不能大于实际可退运费金额",
							bean.getOrderId()), call.getString("msg"), "验证msg");

			DataUtil.verifyDecimalEquals(BigDecimal.ZERO, new BigDecimal(call
					.getData().getDouble("refundFreight")), "验证refundFreight");

			Logger.verifyEquals(false, call.getData().getBoolean("success"),
					"验证success");

			// 数据库验证
			YmtRefundWapper ymtRefund = new YmtRefundWapper();
			SalesRefundInfoBean refundInfoBean = applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0);

			String refundBillNo = bean.getRefundBillNo();

			Map m = new HashMap();

			m.put("orderId", orderId);
			m.put("refundBillNo", refundBillNo);

			YmtRefundBill refundBill = ymtRefund.selectRefundBill(m).get(0);

			YmtRefundProduct refundPro = ymtRefund.selectRefundProduct(m)
					.get(0);

			Logger.comment("校验Ymt_RefundBill表");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundBill.getRefundBillNo(),
					"验证RefundBillNo");

			DataUtil.verifyDecimalEquals(refundInfoBean.getRefundAmount(),
					refundBill.getRefundAmount(), "验证RefundAmount");
			Logger.verifyEquals(0, refundBill.getRefundStatus(),
					"验证RefundStatus");
			DataUtil.verifyDecimalEquals(refundInfoBean.getRefundAmount(),
					refundBill.getSettlementAmount(), "验证SettlementAmount");
			Logger.verifyEquals(-10, refundBill.getSalesRefundStatus(),
					"验证SettlementStatus");
			Logger.verifyEquals(refundInfoBean.getRefundType(),
					refundBill.getRefundType(), "验证RefundType");
			Logger.verifyEquals(refundInfoBean.getReason(),
					refundBill.getReason(), "验证Reason");
			Logger.verifyEquals(sellerId, refundBill.getSellerId(),
					"验证SellerId");
			Logger.verifyEquals(userId, refundBill.getBuyerId(), "验证BuyerId");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");

			DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
					refundBill.getRefundedAmountOfFreight(),
					"验证RefundedAmountOfFreight");

			Logger.comment("校验Ymt_RefundProduct表");
			Logger.verifyEquals(orderId, refundPro.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundPro.getRefundBillNo(),
					"验证RefundBillNo");
			Logger.verifyEquals(refundInfoBean.getCatalogId(),
					refundPro.getCatalogId(), "验证CatalogId");

			Logger.verifyEquals(refundInfoBean.getRefundProductNum(),
					refundPro.getRefundProductNum(), "验证RefundProductNum");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReapplyRefund_005() {
		Logger.start(true, "对已关闭退单重新开启成功,校验退的运费");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder7();

			Order order = placeOrderResp.getOrderList().get(0);

			int sellerId = order.getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			int orderId = order.getOrderId();

			OrderCallService orderCallService = new OrderCallService();

			BigDecimal amount = placeOrderResp.getPayAmount();
			// 付款
			orderCallService.orderPayRequest(userId, amount, tradingId);
			// 卖家接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 发货
			orderCallService.dispatched(orderId, sellerId);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			orderCallService
					.salesrefundfailrequest(applySalesRefundRequestBean);

			OrderInfoPo po = order.getOrderInfoList().get(0);

			// 计算订单总价格 商品价格 X 数量+运费
			BigDecimal refoundAmout = po.getProductPrice()
					.multiply(new BigDecimal(po.getAmount()))
					.subtract(po.getYmtCouponAmount())
					.subtract(po.getSellerCouponAmount()).add(po.getFreight());

			bean.setOrderId(orderId);
			bean.setRefundAmount(refoundAmout);
			bean.setRefundBillNo(applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0).getRefundBillNo());
			bean.setRefundProductNum(po.getAmount());

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("200", call.getString("code"), "验证code");

			Logger.verifyEquals("0", call.getString("bcode"), "验证bcode");

			DataUtil.verifyDecimalEquals(po.getFreight(), new BigDecimal(call
					.getData().getDouble("refundFreight")), "验证refundFreight");

			Logger.verifyEquals(true, call.getData().getBoolean("success"),
					"验证success");

			// 数据库验证
			YmtRefundWapper ymtRefund = new YmtRefundWapper();
			SalesRefundInfoBean refundInfoBean = applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0);

			String refundBillNo = bean.getRefundBillNo();

			Map m = new HashMap();

			m.put("orderId", orderId);
			m.put("refundBillNo", refundBillNo);

			YmtRefundBill refundBill = ymtRefund.selectRefundBill(m).get(0);

			YmtRefundProduct refundPro = ymtRefund.selectRefundProduct(m)
					.get(0);

			Logger.comment("校验Ymt_RefundBill表");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundBill.getRefundBillNo(),
					"验证RefundBillNo");

			DataUtil.verifyDecimalEquals(bean.getRefundAmount(),
					refundBill.getRefundAmount(), "验证RefundAmount");
			Logger.verifyEquals(0, refundBill.getRefundStatus(),
					"验证RefundStatus");
			DataUtil.verifyDecimalEquals(bean.getRefundAmount(),
					refundBill.getSettlementAmount(), "验证SettlementAmount");
			Logger.verifyEquals(1, refundBill.getSalesRefundStatus(),
					"验证SettlementStatus");
			Logger.verifyEquals(refundInfoBean.getRefundType(),
					refundBill.getRefundType(), "验证RefundType");
			Logger.verifyEquals(refundInfoBean.getReason(),
					refundBill.getReason(), "验证Reason");
			Logger.verifyEquals(sellerId, refundBill.getSellerId(),
					"验证SellerId");
			Logger.verifyEquals(userId, refundBill.getBuyerId(), "验证BuyerId");
			Logger.verifyEquals(orderId, refundBill.getOrderId(), "验证OrderId");

			DataUtil.verifyDecimalEquals(po.getFreight(),
					refundBill.getRefundedAmountOfFreight(),
					"验证RefundedAmountOfFreight");

			Logger.comment("校验Ymt_RefundProduct表");
			Logger.verifyEquals(orderId, refundPro.getOrderId(), "验证OrderId");
			Logger.verifyEquals(refundBillNo, refundPro.getRefundBillNo(),
					"验证RefundBillNo");
			Logger.verifyEquals(refundInfoBean.getCatalogId(),
					refundPro.getCatalogId(), "验证CatalogId");

			Logger.verifyEquals(bean.getRefundProductNum(),
					refundPro.getRefundProductNum(), "验证RefundProductNum");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReapplyRefund_006() {
		Logger.start(true, "订单号不存在");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			Order order = placeOrderResp.getOrderList().get(0);

			int sellerId = order.getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			int orderId = order.getOrderId();

			OrderCallService orderCallService = new OrderCallService();

			BigDecimal amount = placeOrderResp.getPayAmount();
			// 付款
			orderCallService.orderPayRequest(userId, amount, tradingId);
			// 卖家接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 发货
			orderCallService.dispatched(orderId, sellerId);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			/*			orderCallService
								.salesrefundfailrequest(applySalesRefundRequestBean);*/

			bean.setOrderId(11111);
			bean.setRefundAmount(BigDecimal.TEN);
			bean.setRefundBillNo(applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0).getRefundBillNo());
			bean.setRefundProductNum(1);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("201", call.getString("code"), "验证code");
			Logger.verifyEquals("110", call.getString("bcode"), "验证bcode");
			Logger.verifyEquals(
					String.format("退款单%s不存在", bean.getRefundBillNo()),
					call.getString("msg"), "验证msg");

			Logger.verifyEquals(false, call.getData().getBoolean("success"),
					"验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReapplyRefund_007() {
		Logger.start(true, "退款单不存在");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			Order order = placeOrderResp.getOrderList().get(0);

			int sellerId = order.getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			int orderId = order.getOrderId();

			OrderCallService orderCallService = new OrderCallService();

			BigDecimal amount = placeOrderResp.getPayAmount();
			// 付款
			orderCallService.orderPayRequest(userId, amount, tradingId);
			// 卖家接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 发货
			orderCallService.dispatched(orderId, sellerId);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			/*			orderCallService
								.salesrefundfailrequest(applySalesRefundRequestBean);*/

			bean.setOrderId(orderId);
			bean.setRefundAmount(BigDecimal.TEN);
			bean.setRefundBillNo("234234");
			bean.setRefundProductNum(1);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("201", call.getString("code"), "验证code");
			Logger.verifyEquals("110", call.getString("bcode"), "验证bcode");
			Logger.verifyEquals(
					String.format("退款单%s不存在", bean.getRefundBillNo()),
					call.getString("msg"), "验证msg");

			Logger.verifyEquals(false, call.getData().getBoolean("success"),
					"验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReapplyRefund_008() {
		Logger.start(true, "订单号为null");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			Order order = placeOrderResp.getOrderList().get(0);

			int sellerId = order.getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			int orderId = order.getOrderId();

			OrderCallService orderCallService = new OrderCallService();

			BigDecimal amount = placeOrderResp.getPayAmount();
			// 付款
			orderCallService.orderPayRequest(userId, amount, tradingId);
			// 卖家接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 发货
			orderCallService.dispatched(orderId, sellerId);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			//bean.setOrderId(11111);
			bean.setRefundAmount(BigDecimal.TEN);
			bean.setRefundBillNo(applySalesRefundRequestBean
					.getSalesRefundInfoList().get(0).getRefundBillNo());
			bean.setRefundProductNum(1);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("400", call.getString("code"), "验证code");
			Logger.verifyEquals("100", call.getString("bcode"), "验证bcode");
			Logger.verifyEquals("orderId:订单号不能为空", call.getString("msg"),
					"验证msg");

			Logger.verifyEquals(false, call.getData().getBoolean("success"),
					"验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReapplyRefund_009() {
		Logger.start(true, "退款单号为null");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			Order order = placeOrderResp.getOrderList().get(0);

			int sellerId = order.getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			int orderId = order.getOrderId();

			OrderCallService orderCallService = new OrderCallService();

			BigDecimal amount = placeOrderResp.getPayAmount();
			// 付款
			orderCallService.orderPayRequest(userId, amount, tradingId);
			// 卖家接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 发货
			orderCallService.dispatched(orderId, sellerId);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			bean.setOrderId(11111);
			bean.setRefundAmount(BigDecimal.TEN);
			/*			bean.setRefundBillNo(applySalesRefundRequestBean
								.getSalesRefundInfoList().get(0).getRefundBillNo());*/
			bean.setRefundProductNum(1);

			call.setData(bean);
			call.callService();

			Logger.verifyEquals("400", call.getString("code"), "验证code");
			Logger.verifyEquals("100", call.getString("bcode"), "验证bcode");
			Logger.verifyEquals("refundBillNo:退款单号不能为空", call.getString("msg"),
					"验证msg");

			Logger.verifyEquals(false, call.getData().getBoolean("success"),
					"验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
